home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / Prog / B-C / Color Window Demo / menu selection.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-01-30  |  2.1 KB  |  91 lines  |  [TEXT/KAHL]

  1. #include "my color.h"
  2.  
  3.  
  4. /*Execute Item specified by mResult, the result of MenuSelect*/
  5. DoCommand(mResult)
  6. long        mResult;
  7.  
  8. {
  9.     short        theItem;        /*menu item number from mResult low-order word*/
  10.     short        theMenu;        /*menu number from mResult high-order word*/
  11.     char        name[256];    /*desk accessory name*/
  12.  
  13.  
  14.     theItem = LoWord(mResult);            /*call Toolbox Utility routines to set */
  15.     theMenu = HiWord(mResult);            /* menu item number and menu number*/
  16.     
  17.     switch (theMenu)                            /*switch on menu ID*/
  18.     {
  19.         case appleID:
  20.             if (theItem == aboutItem)
  21.                 DoAboutBox();
  22.             else
  23.             {                                                
  24.                 GetItem(myMenus[appleM],theItem,name);
  25.                 /*GetPort (&savedPort);*/
  26.                 scrapErr = ZeroScrap(); 
  27.                 scrCopyErr = TEToScrap();
  28.                 (void) OpenDeskAcc(name);
  29.                 EnableItem (myMenus [editM],0);
  30.                 /*SetPort (savedPort);*/
  31.                 if (FrontWindow() != nil)
  32.                 {
  33.                     EnableItem (myMenus [fileM], closeItem);
  34.                     EnableItem (myMenus [editM], undoItem);
  35.                 } /*if FrontWindow*/
  36.                 menusOK = false;
  37.             }    /*if theItem...else*/
  38.             break;
  39.         case fileID:
  40.             switch (theItem) 
  41.             {
  42.                 case newItem:
  43.                     OpenWindow();
  44.                     break;
  45.                 case closeItem:
  46.                     if (((CWindowPeek)FrontWindow())->windowKind < 0)
  47.                         CloseDeskAcc(((CWindowPeek)FrontWindow())->windowKind);
  48.                         /*if desk acc window, close it*/
  49.                     else 
  50.                         KillWindow(FrontWindow());
  51.                         /*if it's one of mine, blow it away*/
  52.                     break;
  53.                 case quitItem:
  54.                     doneFlag = true; /*quit*/
  55.                 break;
  56.             } /*switch theItem*/
  57.             break;
  58.  
  59.          case editID:
  60.                 if (!SystemEdit(theItem-1))
  61.                         switch (theItem)     /*switch on menu item number*/
  62.                         {
  63.                             case cutItem:
  64.                                 TECut(textH);    /*call TextEdit to handle Item*/
  65.                                 break;
  66.                             case copyItem:
  67.                                 TECopy(textH);
  68.                                 break;
  69.                             case pasteItem:
  70.                                 TEPaste(textH);
  71.                                 break;
  72.                             case clearItem:    
  73.                                 TEDelete(textH);
  74.                                 break;
  75.                         }    /*switch theItem*/
  76.                 break;
  77.  
  78.         case colorID:
  79.             change_color(theItem, (CWindowPtr)FrontWindow());
  80.             break;
  81.         
  82.         case controlID:
  83.             change_control_color(theItem, (CWindowPtr)FrontWindow());
  84.             break;
  85.  
  86.     }    /*switch theMenu*/
  87.     HiliteMenu(0);
  88.  
  89. }  /*DoCommand*/
  90.  
  91.